package com.itheima.Test;

import java.util.HashMap;
import java.util.Scanner;

public class Test002 {
    public static void main(String[] args) {
        /*
        有以下字符串：
		String str = “fje你kw我FDQFj你feAF他Eajf他eo2FA我FEjfew”;
	    请编程统计每个字符出现的次数
         */
        HashMap<Character,Integer> map = new HashMap<>();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            //获取每个字符
            char c = s.charAt(i);
            //4.判断字符在集合中是否存在
            if(!map.containsKey(c)){
                map.put(c,1);
            }else{
                map.put(c,map.get(c)+1);
            }
        }
        System.out.println(map);
    }
}
